import 'package:json_annotation/json_annotation.dart';

part 'color.g.dart';

@JsonSerializable(includeIfNull: false, explicitToJson: true)
class ColorStop {
  num? offset;
  var color; //rgba #
  ColorStop({
    this.offset,
    this.color,
  });

  factory ColorStop.fromJson(Map<String, dynamic> json) =>
      _$ColorStopFromJson(json);

  Map<String, dynamic> toJson() => _$ColorStopToJson(this);
}

@JsonSerializable(includeIfNull: false, explicitToJson: true)
class LinearGradient {
  bool? global;
  List<ColorStop>? colorStops;
  String type = "linear"; //"linear"
  num? x;
  num? x2;
  num? y;
  num? y2;

  LinearGradient({
    this.global,
    this.colorStops,
    this.x,
    this.x2,
    this.y,
    this.y2,
  });

  factory LinearGradient.fromJson(Map<String, dynamic> json) =>
      _$LinearGradientFromJson(json);

  Map<String, dynamic> toJson() => _$LinearGradientToJson(this);
}

@JsonSerializable(includeIfNull: false, explicitToJson: true)
class RadialGradient {
  bool? global;
  List<ColorStop>? colorStops;
  String type = "radial"; //"linear"
  num? x;
  num? r;
  num? y;

  RadialGradient({this.global, this.colorStops, this.x, this.y, this.r});

  factory RadialGradient.fromJson(Map<String, dynamic> json) =>
      _$RadialGradientFromJson(json);

  Map<String, dynamic> toJson() => _$RadialGradientToJson(this);
}
